<!DOCTYPE HTML>
<html lang="zh-CN"><head>
<title>{$name}</title>
<meta charset="UTF-8">
<meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<link href="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/css/product/product_detail.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<!-- <script src="http://sdk.talkingdata.com/app/h5/v1?appid=DE13C350F41F5DE78FEC51DB5DE730D1&vn=v2&vc=v2"></script> -->
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/product.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/cookie.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/product/timer.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>	

</head>
<style>
.comnt-img
{
	overflow: hidden;
	width: 100%;
	padding-bottom: 10px;
	height: 60px;
}
.comnt-img > div
{
	display: block;
	
	float: left;
	margin-right: 3%;
	position: relative;
	
}
.comnt-img > div:last-child
{
	margin-right: 0px;
}
.comnt-img > div img
{
	height: 60px;
	display: block;
	margin: 0 auto;
	max-width: 100%;
	
}
.no-comment
{
	
	color: #888;
}

.priceTag
{
	display: inline-block;
	float: left;
	margin: 3px 2px;
	margin-bottom: 5px;
	padding: 1px 5px;
	border-radius: 2px;
	background: #f59300;
	color: white;
	font-size: 12px;
	font-weight: normal;
}
.iteamInfo a
{
	font-weight: normal;
}
.iteamInfo a .ico-iteam
	{
		background: white;
	}
	.iteamInfo a .ico-iteam p
	{
		font-size: 12px;
		color: #FF8F12;
		margin-top: 2px;
		text-align: center;
		line-height: 15px;
	}
	.iteamInfo a .iteamPrice
	{
		font-size: 12px;
		text-decoration: line-through;
		padding: 0px 6px;
	}
	.iteamInfo a .iteamNum
	{
		border: 0px;
		padding-right: 0px;
		border: 0px;
		padding-right: 0px;
		height: 33px;
		line-height: 33px;
		font-size: 15px;
		margin:0;
	}
	.iteamInfo a .iteamNum i{
		font-size:14px;
	}
	.iteamInfo a .toIteam
	{
		background: transparent;
	}
	.tool-box
	{
		z-index: 2;
	}
	.tool-box dd
	{
		columns:initial;
		-webkit-columns:initial;
		display: -webkit-box;
		-webkit-box-orient: horizontal;
	}
	.tool-box dd > a
	{
		width: 0px;
		-webkit-box-flex: 4;
		margin: 0px 2px;
	}
	.tool-box dd > a:first-child
	{
		-webkit-box-flex: 5;
	}
</style>
<body>
	<!--关注浮层 begin-->
	<!--0表示未关注，1表示已关注-->
	<if condition="$subscribe eq '0'">
	<style>
		.careview
		{
			position: fixed;
			top: 0px;
			left: 0px;
			right: 0px;
			padding: 8px 110px 8px 65px;
			background: rgba(0,0,0,0.5);
			z-index: 999;
			color: white;
			height: 61px;
			box-sizing: border-box;
		}
		.careview > span
		{
			content: '';
			display: block;
			position: absolute;
			top: 50%;
			right: 5px;
			background: url({$Think.config.RESOURCEURL}wx_assets/images/careclose.png) no-repeat;
			width:18px;
			height: 18px;
			margin-top: -9px;
			background-size: contain;
			opacity: 0.8;
		}
		.careview > img
		{
			display: block;

			width: 45px;
			height: 45px;
			border-radius: 4px;
			position: absolute;
			top: 50%;
			left: 10px;
			margin-top: -22px;
		}
		.careview > a
		{
			background: #1c93ce;
			display: block;
			color: white;
			text-align: center;
			border-radius: 4px;
			width: 75px;
			height: 35px;
			line-height: 35px;
			font-size: 14px;
			top: 50%;
			margin-top: -17px;
			right:35px;
			position: absolute;

		}
		.careview > p
		{
			display: inline-block;
			vertical-align: middle;
			font-size: 14px;
			padding: 3px 0px;
			max-height: 38px;
			overflow: hidden;
			height: 100%;
			line-height: 38px;
		}
	</style>
	<div class="careview">
		<img src="{$mall.logo}" alt="" />
		<a href='{$mall.wechaturl}'>立即关注</a>
		<empty name="mall.recommend">
			<p>{$mall.wechatname}</p>
			<else />
			<p>{$mall.recommend}</p>
		</empty>

		<span></span>
	</div>
	<script>
		$('.careview > span').on('click',function(){
			$('.careview').hide();
		});
	</script>
	</if>
	<!--关注浮层 end-->
<notempty name="headerTpl">
	<include file="$headerTpl" />
</notempty>
        <!--<div class="shop-box">
           <a href="{$mall.storeurl}">{$mall.name}</a>
            <a href="{$mall.wechaturl}" class="fr">关注</a>
        </div>-->
    <div class="detail-slider-container" style="margin-top: 0px;position:relative">
        <ul class="pro-list" id="detail-slider" >
            <volist name="picUrl1" id="picItem">
                <if condition="$i neq '1'">
                    <li l="true">
                        <img class="default" src="{$picItem:picUrl}">
                    </li>
                </if>
            </volist>
        </ul>
		<if condition = "$inventory eq '1' AND $inventoryCount elt '0'">
			<div class="soldOut"></div>
		</if>
	</div>
    <script type="text/javascript">
    mi.PRODUCT_DETAIL._initSlide();       
    </script>
    <if condition="$playType eq '4'">

    	 	<style>
    	 		.seckill
    	 		{
    	 			padding: 10px 5px;
    	 			background: #f69301;
    	 			color:white;
    	 			height: 40px;
    	 		}
    	 		.seckill span
    	 		{
    	 			display: inline-block;
    	 		}

    	 		.seck-bpri b
    	 		{
    	 			font-size: 30px;
    	 		}
    	 		.seck-spri
    	 		{
    	 			margin-left: 10px;
    	 			font-size: 13px;
    	 		}
    	 		.secktimer
    	 		{

    	 			float: right;
    	 			height: 40px;
    	 			line-height: 40px;
    	 			font-size: 15px;
    	 		}
    	 	</style>
    	 	<div class="seckill">
						 <if condition="$minDisPrice neq $maxDisPrice and $supportSpecification eq '1'">
							 <span class="seck-bpri" id="price">￥{$minDisPrice|floatval}~{$maxDisPrice|floatval}</span>
							 <elseif condition="$minDisPrice gt 0 and $supportSpecification eq '1'"/>
							 <span class="seck-bpri" id="price">￥{$minDisPrice|floatval}</span>
							 <elseif condition="$minFixedPrice neq $maxFixedPrice and $supportSpecification eq '1'"/>
							 <span class="seck-bpri" id="price">￥{$minFixedPrice|floatval}~{$maxFixedPrice|floatval}</span>
							 <elseif condition="$supportSpecification eq '1'"/>
							 <span class="seck-bpri" id="price">￥{$minFixedPrice|floatval}</span>
						 <else/>
						 <notempty name="discountedPrice">
						 <span class="seck-bpri">￥<b>{$discountedPrice}</b></span>
						 <span class="seck-spri"><i style="text-decoration: line-through;">￥{$fixedPrice} </i><!--<br />已抢购{$seckillNum}件--></span>
						 </notempty>
						 <empty name="discountedPrice">
						 <span class="seck-bpri">￥<b>{$fixedPrice}</b></span>
						 <!--<span class="seck-spri">已抢购{$seckillNum}件</span>-->
						 </empty>
						 </if>
			         <span class="secktimer">
			         	<if condition="$seckillIsEnd eq '1'">
							已抢完
						<elseif condition="$seckillIsStart eq '1'"/>
				         	<p style="display:inline;color: white;" class="lxftime" nowtime="{$nowTime}" endtime="{$seckillEndtime}" col="0" lxfday="no" lxftext="距结束"></p>
		                <else />
		                  	 <!--{$seckillStartTime}-->
		                  	 <!--<php>echo date("H:i:s",strtotime($seckillStartTime));</php>-->

		                  	 <p style="display:inline;color: white;" class="lxftime" nowtime="{$nowTime}" endtime="{$seckillStartTime}" starttime="{$seckillEndtime}" col="0" lxfday="no" lxftext="距开始"></p>
	                    </if>
			         </span>
    	 	</div>
    	 	<script>
    	 		lxfEndtime();
    	 	</script>
   	</if>
    <div class="pro-box">
        <dl class="pro-name">
            <dt>
                <h1>
                    <if condition="$freeBuy eq '1'">
                        <span>我要代言</span>&nbsp;
                    </if>
                    <if condition="$teambuy eq '1'">
                        <span>组团购</span>&nbsp;
                    </if>
                    {$name}
                </h1>
            </dt>
            <dd>
                <if condition = "$favorite eq 0">
                    <div class="fav" id="favorite" productid="{$id}" favorite="{$favorite}">
                        <span>收藏</span>
                    </div>
                    <else />
                    <div class="fav fav1">
                        <span>已收藏</span>
                    </div>
                </if>
            </dd>
        </dl>
        <div class="price" style="overflow: hidden;">
            <if condition="$freeBuy eq '1'">
				<style>
					.price{
						height: 26px;
					}
				</style>
				<div style="float: left;">
					￥{$freeBuyMoney[0]}~￥<php>echo end($freeBuyMoney);</php>
				</div>
				<volist name="priceTag" id="pct">
					<span class="priceTag">{$pct}</span>
				</volist>
                <elseif condition="$teambuy eq '1'"/>
                <div class="iteamInfo">
                    <a>
                        <div class="ico-iteam">
                        	<p>{$teamCount}<br />人团</p>
                        </div>
                        <div class="iteamNum">
                            <i>&yen;</i><span style="font-size:20px">{$teamPrice}</span>
                            <del style="display: inline-block;color:#fff;font-size:12px;margin-left:5px"><i style="font-size:12px">&yen;</i>{$fixedPrice}</del>
                        </div>
                        <div class="iteamTime"></div>
                    </a>
                </div>
				<notempty name="priceTag">
					<div style="margin-top:10px;overflow: hidden;padding: 5px 0;background-color: #eee;display: flex;display: -webkit-flex;justify-content: space-around;-webkit-flex-flow: row wrap;flex-flow: row wrap;-webkit-justify-content: space-around;">
						<volist name="priceTag" id="pct">
							<span class="priceTag" style="background-color: #009DDF;float:left">{$pct}</span>
						</volist>
					</div>
				</notempty>
				<elseif condition="$playType eq '4'"/>
				 <volist name="priceTag" id="pct">
                    <span class="priceTag">{$pct}</span>
                </volist>
				<elseif condition="$playType eq '5' AND $isEnjoyMiPrice eq '1'"/>
				<if condition="$supportSpecification eq '1' and $minMiPrice neq $maxMiPrice">
					<div id="price" style="float: left;">密友价：￥{$minMiPrice|floatval}~{$maxMiPrice|floatval}</div>
					<elseif condition="$supportSpecification eq '1'"/>
					<div id="price" style="float: left;">密友价：￥{$minMiPrice|floatval}</div>
					<else/>
					<div id="price" style="float: left;">密友价：￥{$miPrice|floatval} <del>￥{$fixedPrice|floatval}</del></div>
				</if>
					<volist name="priceTag" id="pct">
						<span class="priceTag">{$pct}</span>
					</volist>
                <else/>
                <div style="float: left;" id="price">
						<if condition="$minDisPrice gt 0 and $minDisPrice neq $maxDisPrice and $supportSpecification eq '1'">
							￥{$minDisPrice|floatval}~{$maxDisPrice|floatval}
							<elseif condition="$minDisPrice gt 0 and $supportSpecification eq '1'"/>
							￥{$minDisPrice|floatval}
							<elseif condition="$minFixedPrice neq $maxFixedPrice and $supportSpecification eq '1'"/>
							￥{$minFixedPrice|floatval}~{$maxFixedPrice|floatval}
							<elseif condition="$supportSpecification eq '1'"/>
							￥{$minFixedPrice|floatval}
						<else/>
						<notempty name="discountedPrice">
							￥{$discountedPrice|floatval}
							<del>￥{$fixedPrice|floatval}</del>
						</notempty>
						<empty name="discountedPrice">
							￥{$fixedPrice|floatval}
						</empty>
						</if>
                </div>
                <volist name="priceTag" id="pct">
                    <span class="priceTag">{$pct}</span>
                </volist>
            </if>
            	
        </div>
		<if condition="$quanInfo neq ''">
			<div class="price" style="overflow: hidden;font-size:12px">
				密友立省{$isMiUserCut}元(仅密友可见)
			</div>
		</if>
        <div id="prop-list" class="mod_property prop-list">
        </div>
        <if condition = "(($fixedPrice neq NULL) OR ($points neq NULL))">
            <dl class="buy-num">
                <dt>数量：</dt>
                <dd>
                    <span class="quantity">
                        <span class="minus disabled" tag="sub" id="sub"></span>
                        <input type="tel" id="buyNum" value="1" readonly="readonly" inventory="{$inventory}" data-total="{$surplusNum}" data-ktotalkey="{$inventory}" data-ktotal="{$inventoryCount}" />
                        <if condition = "$inventory eq '1' AND $inventoryCount eq '0' and $supportSpecification eq '0'">
                            <span tag="add" class="plus disabled" id="plus"></span>
                        <else/>
                            <span tag="add" class="plus" id="plus"></span>
                        </if>
                    </span>
					<if condition = "$inventory eq '1'">
							<span class="inventory" id="inventory_count">&nbsp;剩余<span id="stock-num">{$inventoryCount}</span>件</span>
					</if>
                </dd>
            </dl>
        </if>
    </div>
    <div class="pro-detail" style="padding-bottom: 75px;">
        <ul class="tab" id="Tab" style="-webkit-Column-count:2">
            <li class="select">商品详情</li>
            <li id="TabComment">晒单分享</li>
        </ul>
        <div class="tab-content" id="TabContent">
            <div class="p-detail" style="display:block">
                {$webPageContent}
            </div>
            <div class="p-comment" id="p-comment">
            </div>
        </div>
    </div>
    <div class="tool-box">
       <dl>
           <if condition="$teambuy eq '1'">
               <dd style="margin-left:0">
                   <a class="add-car iteamBtn <if condition='$isStart neq 1 OR $isEnd eq 1'>btn-disabled</if>" id="buy-team" data-type="team"><span>去开团</span><span>{$teamPrice}/件</span></a>
                   <a class="buy iteamBtn <if condition='$isStart neq 1 OR $isEnd eq 1'>btn-disabled</if>" id="buy-now" data-type="now"><span>直接购买</span>
                       <notempty name="discountedPrice">
                           <span>{$discountedPrice}/件</span>
                       </notempty>
                       <empty name="discountedPrice">
                           <span>{$fixedPrice}/件</span>
                       </empty>
                   </a>
               </dd>
               <if condition='$isStart neq 1 OR $isEnd eq 1 or $hasList neq 1'>
				   <else />
				   <a class="btn-goteam" href="call.html?module=tuan&customerId={$customerId}&method=getTeamOrderList&params=%7B%22pid%22:{$id}%7D">即将成功的团</a>
               </if>
               <else/>
               <dt>
               <a id="car" class="car" onclick="detail.goCart('{$vId}')" >
                   <div class="num" id="carNum"></div>
               </a>
               </dt>
               <dd>
                   <if condition="$inventory eq '1' AND $inventoryCount eq '0' AND $supportSpecification eq '0'">
                       <a class="add-car btn-disabled">加入购物车</a>
                       <a class="buy btn-disabled">立即购买</a>
                       <elseif condition="$freeBuy eq '1' AND $virtual eq '1'"/>
                       <a class="add-car btn-disabled" id="addCar">加入购物车</a>
                       <a class="buy" id="buy-now">立即购买</a>
                       <elseif condition="$freeBuy eq '1'"/>
                       <a class="add-car" id="addCar" onclick="detail.selectPrice();">加入购物车</a>
                       <a class="buy" id="buy-now">立即购买</a>
                       <elseif condition="$virtual eq '1'"/>
                       <a class="add-car btn-disabled" id="addCar">加入购物车</a>
                       <a class="buy" id="buy-now">立即购买</a>
                       <elseif condition="$playType eq '4'"/>
						   <php>if($seckillIsEnd!=1&&$seckillIsStart==1){</php>
					   		<a class="add-car" id="addCar" onclick="detail.addToCart(this);">加入购物车</a>
						   <a class="buy" id="buy-now">立即购买</a>
						   <php>}else{</php>
					   		<a class="add-car btn-disabled" id="addCar">加入购物车</a>
						   <a class="buy btn-disabled" id="buy-now">立即购买</a>
						   <php>}</php>
                       <else/>
                       <a class="add-car" id="addCar" onclick="detail.addToCart(this);">加入购物车</a>
                       <a class="buy" id="buy-now">立即购买</a>
                   </if>
               </dd>
          </if>
       </dl>
    </div>
    <if condition="$freeBuy eq '1'">
        <div class="pro-box">
            <div id="free-list" class="mod_property prop-list free-list">
                <div class="closeDiv"><div class="close" id="close"></div></div>
                <dl class="gg" data-value="null">
                    <dt style="float:none">请选择价格</dt>
                    <dd style="margin-top:0">
                        <volist name="freeBuyMoney" id="money">
                            <span data-value="{$money}">{$money}</span>
                        </volist>
                    </dd>
                    <dd style="display:none;margin: 5px 0" id="invitation" class="invitation"></dd>
                </dl>
                <a>确定</a>
            </div>
        </div>
    </if>
    <div id="evaluationpid" style="display:none;">{$id}</div>
    <div class="fav-mask" id="FavMask">
        <div class="msg">
            耶！收藏成功,87%的人点击关注，便于查看收藏的商品。
        </div>
    </div>
<input type="hidden" id="shareImg" value="<php>echo $picUrl1[1]->picUrl;</php>">
<notempty name="footerTpl">
	<include file="$footerTpl"/>
</notempty>
<style>
	.playWarm
	{
		position: fixed;
		top: 0px;
		left: 0px;
		right: 0px;
		bottom: 0px;
		z-index: 1;
		background: rgba(0,0,0,0.6);
		display: none;
	}
	.playWarm > div
	{
		width: 280px;
		margin: 0 auto;
	}
	.playWarm > div 
	{
		border-radius: 5px;
		/*height: 85%;
		overflow-y: auto;
		-webkit-overflow-scrolling:touch;*/
		background: white;
		width: 280px;
		margin: 0 auto;
		position: absolute;
		
		top: 50%;
		left: 50%;
		-webkit-transform: translate(-50%,-55%);
	}
	.playWarm > div > div
	{
		border-radius: 5px;
	}
	.playWarm.small > div > div
	{
		overflow-y: auto;
		-webkit-overflow-scrolling:touch;
		height: 380px;
		
	}
	.playWarm > div > div > img
	{
		border-radius: 5px;
		display: block;
		margin: 0 auto;
		max-width: 100%;
		
	}
	.playWarm > div  .closeWarm
	{
		position: absolute;
		top: -8px;
		right: -10px;
		display: block;
		width: 28px;
		height: 28px;
		background: url({$Think.config.RESOURCEURL}wx_assets/tuan/img/closeWarm.png);
		background-size: contain;
		z-index: 999;
	}
</style>
<div class="playWarm">
	<div>
		<a onclick="hidePlayWarm()" class="closeWarm"></a>
		<div>
			<img src="{$Think.config.RESOURCEURL}wx_assets/tuan/img/warm.png"/>
		</div>
	</div>
</div>
<script type="text/template" id="prop-tpl">
<dl class="gg" data-value="{#availSku#}">
    <dt class="{#propClass#}">{#pName#}：</dt>
    <dd skuname="{#pName#}" index="{#index#}">{#pList#}</dd>
</dl>
</script>
<if condition="$teambuy eq '1'">
<script>
if($(window).height()<500)
	{
		$('.playWarm').addClass('small')
	}
	function hidePlayWarm(){
		$('.playWarm').hide();
		setCookie('playFirst',1);
	}
	var isFirst=getCookie('playFirst');
	//第一次来,弹出提示
	if(isFirst==null)
	{
		
		$('.playWarm').show();
		
	}
	else if(isFirst==1)
	{
		$('.playWarm').hide();
	}
	
</script>
</if>
<script type="text/javascript" charset="utf-8">
  var previewImageUrls=[];
  var pImgs=$(".p-detail img");
  pImgs.each(function(){
        var url=$(this).attr("src") || $(this).attr("original");
        previewImageUrls.push(url);
  });
  //图片预览
  pImgs.click(function(){
        var url=$(this).attr("src") || $(this).attr("original");
        var par=$(this).parent();
        if(par && par.length>0 && par[0].tagName.toUpperCase()!=="A"){
            wx.previewImage({
              current: url,
              urls: previewImageUrls
           });
        }
  })
</script>
<script type="text/html" id="commentTpl">
    <%if(list && list.length){
    for(var i=0;i<list.length;i++){
    var item = list[i];
    var imgs = list[i].imgurl;
     item.RESOURCEURL="{$Think.config.RESOURCEURL}";
    %>
    <div class="main">
        <div class="info">
			<%if(item.headImgUrl) {%>
    			<span class="head"><img src="<%=item.headImgUrl%>"></span>
                <span class="name"><%=item.nickName%></span>
            <%} else {%>
                <span class="head"><img src="<%=item.RESOURCEURL%>wx_assets/images/defaultHeadImg.png"></span>
                <span class="name">匿名用户</span>
            <%}%>
            <span class="time"><%=item.createTime%></span>
        </div>
        <div class="commen"><%=item.comment%></div>
        <%if(imgs && imgs.length){%>
            <div class="comnt-img">
                   <% for (var y=0;y<imgs.length;y++) {%>
                    <div>
                        <img src="<%=imgs[y]%>@320h_320w_1e_1c"/>
                    </div>
                    <%}%>
            </div>
        <%}%>
        <%if(item.sizeName) {%>
            <div class="spec">规格：<%=item.sizeName%>&nbsp;&nbsp;<%=item.colorName%></div>
        <%}%>
    </div>
    <%}}else{%>
    <div class='no-comment'>来晒单嘛！有了你，我就不再孤独！</div>
    <%}%>
</script>
<script type="text/javascript">
    var pid = {$id};
	var favoriteCount = {$favoriteCount};
	var availSku = '{$availSku}';
	availSku = encodeURIComponent(availSku);
	var sku = new Array();
    var orderType, availSku, cku, totalStock, bookEndTime, bookBeginTime, isNew, wxInfo;
    var size = {$size};
    if (size != null) {
    	var sizeUnit = "{$sizeUnit}";
        var sizeUrl = JSON.parse('{$sizeurl}');
    	sku.push({"pList": size, "pName":sizeUnit,"pUrl":sizeUrl,"availSku":availSku});
    }
    var color = {$color};
    if (color != null) {
    	var colorUnit = "{$colorUnit}";
        var colorUrl = JSON.parse('{$colorurl}');
    	sku.push({"pList": color, "pName":colorUnit,"pUrl":colorUrl,"availSku":availSku});
    }
    if (size == null && color == null) {
    	sku = [];
    	availSku = [];
    } else {
    	availSku = {$availSku} == null ? [] : {$availSku};
    	$('#inventory_count').hide();
    }
    var inventory = {$inventory};
    var totalInventoryCount = {$inventoryCount};
    var freeBuy = "{$freeBuy}";
    var freeBuyMoney = "{$freeBuyMoney}";
    var price = "{$discountedPrice}"||"{$fixedPrice}";
	var virtual = "{$virtual}";
    $("#free-list").css("bottom",-$("#free-list").height()+"px");
    var orderType = '{$fixedPrice}' === '' ? 'point' : 'buy';
    if (orderType === 'point') {
    	var isMember = parseInt('{$isMember}');
    	var isCheck = parseInt('{$isCheck}');
    	var points = parseInt('{$points}');
    	var myScore = parseInt('{$myScore}');
    }
    var isNew = "false";
    var wxInfo = { "isFocus": "true", "wxId": "ONLY_BESTSELLER" };

</script>
<script type="text/javascript">
var baseUrl = '{$Think.config.SERVER_HOST}';
var hrefPath = baseUrl+'call.html?customerId={$customerId}';
var basePath = baseUrl+'call.json?customerId={$customerId}&userName={$userName}';
var p=$.util.getParamAsObject();
var isTeamPro="{$teambuy}";
var playType = "{$playType}";
var freeBuy = '{$freeBuy}';
var isEnjoyMiPrice = '{$isEnjoyMiPrice}';
var teambuy = '{$teambuy}';
var seckillIsStart = "{$seckillIsStart}";
var distributionId = "{$distributionId}";
var seckillIsEnd = "{$seckillIsEnd}";
var teamId=p.teamId || "";
var buyParams={
	"pids": "{$id}",
	"type": "buy",
	"qId":p.qId||"{$quanInfo.qId}",
	"miUId":p.miUId||"{$quanInfo.uId}",
	"vId":"{$vId}",
	"shareId":"{$sId}",
	"shareFromGuid":p.fromGuid,
    "userName":'{$userName}',
    "visitId":"{$visitId}",
	"distributionId":distributionId,
	"proSource":'{$proSource}'
};
var detail={
    pageSize:30,
    page:0,
    cartList:null,//购物车详情
    guid:"{$guid}",
    init:function(){
        this._initEvent();
        this._initTab();
    },
    /*团购相关扩展*/
    tuan:{
        createTeamOrder: function(oid,callback) {
            var p=$.util.getParamAsObject();
            p.pid="{$id}";
            p.oid=oid;
            $.req.get("call.json?customerId={$customerId}&module=tuan&method=createTeamOrder",{
                userName:"{$userName}",
                params:p
            },function(data){
                if(!data.code){
                   callback && callback(data);
                } else {
                    $.util.alert(data.msg);
                }
            });
        }
    },
    _initTab: function() {
        var me = this;
        $("#Tab li").click(function() {
            var index = $(this).index();
            $(this).addClass('select').siblings().removeClass("select");
            if(index){
                $(".p-comment").show();
                $(".p-detail").hide();
            }else{
                $(".p-comment").hide();
                $(".p-detail").show();
            }
            if(index==1 && !$(this).attr("load")){
                 $.util.pageLoading.show();
                 me._loadList(me.page,function(){
                    $.util.pageLoading.hide();
                 });
                 $(this).attr("load",1);
            }
        });
        $("#prop-list dl").each(function(){
            var dt = $(this).find("dt");
            var dd = $(this).find("dd");
            var width = parseInt(dt.css("width"));
            dd.css("margin-left",width+"px");
        });
        $("#close").click(function(){
            $("#free-list").css("bottom",-$("#free-list").height()+"px");
        });
    },
    _initEvent:function(){
        var me=this;
        $.util.initDataLoading({
            me:detail,
            lastChildren:function(){
                return $("#p-comment .main:last");
            },
            page:function(){
                return detail.page;
            },
            pageCount:function(){
                return detail.pageCount;
            }
        });
    },
    _renderList:function(data,page,callback){
        var me=this;
        if(data){
            var html=template("commentTpl", data),
                    container=$("#p-comment");
            container.append(html);
            me.page=page;
            me.pageCount=data.pageCount;
            callback && callback();
            
            showImg();
        }
    },
    _loadList:function(page,callback){
        var me=this;
        if($("#TabComment").hasClass("select")){
            $.req.get("call.json?module=product&customerId={$customerId}&method=getcommentList",{
                userName:"{$userName}",
                params:{
                    "pid":"{$id}",
                    "start":page,
                    "limit":me.pageSize
                }
            },function(data){
                if(data){
                    me._renderList(data,page,callback);
                }
            });
        }
    },
    getShareUrl:function(){
        var p=$.util.getParamAsObject();
        var shareUrl="";
        var me=this;
		var mallQId = "{$quanInfo.qId}";
		var mallUId = "{$quanInfo.uId}";
        if(p.qId||(mallQId&&mallUId)){
			var params={
				"id":"{$id}",
				"fromUserName":"{$userName}",
				"qId":p.qId||mallQId,
				"miUId":p.miUId||mallUId
			}
        }else{
            var params={
                "id":"{$id}",
				"fromUserName":"{$userName}"
            }
        }
		params=encodeURIComponent(JSON.stringify(params));
		shareUrl=baseUrl+'call.html?customerId={$customerId}&module=product&method=getProduct&params='+params;
        return shareUrl;
    },
    goCart:function(vId){
        var p=$.util.getParamAsObject();
        var params=$.extend(p,{
            "sid":"-1",
            "type":"buy",
            "tplid":"4",
            "mid":4,
            "vId":vId,
			"qId":p.qId||"{$quanInfo.qId}",
			"miUId":p.miUId||"{$quanInfo.miUId}"
        });
       params=encodeURIComponent(JSON.stringify(params));
       location.href = 'call.html?customerId={$customerId}&module=product&method=getCart&params=' + params;
    },
    carInfo:function(){
        var me = this;
        if($("#prop-list dl").length>0 && inventory) {
            var pros = [];
            var prosName = [];
            $("#prop-list dl").each(function (i) {
                $(this).find("span").each(function () {
                    if ($(this).hasClass("current")) {
                        if (i == 0) {
                            size = $(this).data("value");
                        }
                        if (i == 1) {
                            color = $(this).data("value");
                        }
                        pros.push($(this).data("value"));
                        prosName.push($(this).text());
                    }
                });
            });
            pros = pros.join("|");
            var key = pid + "|" + pros;
            return me.cartList[key];
        }else{
            return me.cartList[pid];
        }
    },
    selectPrice:function(){
        var me = this;
        $("#free-list").css({"bottom":0,"visibility":"visible"});
        var freeBuy = parseInt('{$freeBuy}');
        if( freeBuy){$("#free-list span.current").removeClass("current");$("#invitation").hide();}
        $("#free-list a").click(function(){
            var freeBuy = parseInt('{$freeBuy}');
            if( freeBuy&&!$("#free-list span").hasClass("current")){$.util.alert("没有选择价格");return;}
            $("#free-list").css("bottom",-$("#free-list").height()+"px");
            $("#free-list").one("webkitTransitionEnd",function(){
                var addCar = document.getElementById("addCar");
                me.addToCart(addCar);
            })
        });
    },
    addToCart:function(ctrl) {
        if($(ctrl).hasClass("btn-disabled")){return;}
        var index = $(".ui-slider-dots .ui-state-active").index();
        var img = $("div.ui-slider img:eq("+index+")");
        var imgclone = img.clone();
        var offset = img.offset();
        var endOffset=$("#car").offset();
        var me=this;
         var pop='';
         var size = '';
         var color = '';
         var d = $("#buyNum");
         var num = $("#buyNum").val();
         var supportSpecification='{$supportSpecification}' || 0;
         var first=$("#prop-list dl").eq(0);
         var second=$("#prop-list dl").eq(1);
         var p=$.util.getParamAsObject();

         if(parseInt(supportSpecification)) {
             if($("#prop-list dl").size()>0){
                if((first && !first.find(".current").size()) ){
                    var name ="{$sizeUnit}";
                    $.util.alert("请选择"+name+"!");
                    return false;
                }
                 if(second.length>0 && !second.find(".current").size()){
                     var name ="{$colorUnit}";
                     $.util.alert("请选择"+name+"!");
                     return false;
                 }
             }
         }
         var pros=[];
         var prosName=[];
         $("#prop-list dl").each(function(i){
            $(this).find("span").each(function(){
                if($(this).hasClass("current")){
                    if(i==0){
                        size = $(this).data("value");
                    }
                    if(i==1){
                        color = $(this).data("value");
                    }
                    pros.push($(this).data("value"));
                    prosName.push($(this).text());
                }
            });
        });
        pros=pros.join("|");
        var pNum=0;//购物车中已经添加的商品数量
        if($("#prop-list dl").length>0 && inventory){
            var availSku = $("#prop-list dl").eq(0).data('value');
            var tmp = decodeURIComponent(availSku);
            var kc = JSON.parse(tmp);
            var nowKc=0;
            var key=pid+"|"+pros;
            var msg="超出库存限制";
            if(me.cartList && me.cartList[key]) {
                var pro=me.cartList[key];
                pNum=pro.count;
            }
            if(pros){
                nowKc=parseInt(kc[pros].stockCount);
            }
            if((parseInt(pNum)+parseInt(num))>nowKc){
                return $.util.alert(msg);
            }
        }else{
            if(me.cartList && me.cartList[pid]) {
                pNum=me.cartList[pid].count;
            }
            if (d.data('ktotalkey') == 1 && d.data('ktotal') != null && (parseInt(pNum)+parseInt(num)) > parseInt(d.data('ktotal'))) {
                 return $.util.alert('购买数量不能超过库存限制');
            }
        }
        var freeBuy = "{$freeBuy}";
        var pa={
            "pid":"{$id}",
            "type":"buy",
            "count":num,
            "size":size,
            "color":color,
            "qId":p.qId||"{$quanInfo.qId}",
            "miUId":p.miUId||"{$quanInfo.uId}",
            "vId":p.vId,
            "shareId":p.sId,
            "shareFormGuid":p.fromGuid || "",
            "visitId":"{$visitId}"
        };
        if(freeBuy){
            pa.deposit=$("#free-list span.current").data("value");
        }
        imgclone.addClass("addcar")
        .css({
            "left":"120px",
            "top":$.util.page.getViewHeight()-80+"px"
        });
        $("body").append(imgclone);
        $.req.get("call.json?module=product&customerId={$customerId}&method=updateOrderDetail",{
            userName:"{$userName}",
            params:pa
        },function(data){
            if(data.code){
                imgclone.remove();
                $.util.alert(data.msg);
            } else {
                imgclone.css({
                    left:'20px',
                    top:$.util.page.getViewHeight()-50+"px"
                });
                imgclone.one("webkitTransitionEnd",function(){
                    mi.PRODUCT_DETAIL.getCartGoodsNum();
                    imgclone.remove();
                });
            }
        });
    }

}
mi.PRODUCT_DETAIL.init({$id});
detail.init();
var shareUrl=detail.getShareUrl();
wx_share.init({
        "title":"{$title}",
        "desc":'{$recommend}',
        "link":shareUrl,
        "imgUrl": $.trim($("#shareImg").val()),
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": {$pkg.timestamp},
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        success:function(config,shareType){
            var p=$.util.getParamAsObject();
            $.req.get("call.json?customerId={$customerId}&module=quan&method=saveShare",{
                params:{
                    "qId":p.qId,
                    "sId":"{$sId}",
                    "guid":detail.guid,
                    "fromGuid":p.fromGuid || "",
                    "miUId":p.miUId,
                    "shareType":shareType,
                    "fromPage":"product_detail"
                }
            },function(data){
                if(data && !data.code){
                   detail.guid=data.guid;
                }
            });
        }
 });
 var showImg=function(){

	$('.comnt-img').each(function(){
		var imgs=new Array;
		$(this).children().each(function(){
			var _index=$(this).find('img').attr('src').split('@')[0];
			imgs.push(_index);
		})
		$(this).children().unbind('click');
		$(this).children().on('click',function(){
			
			var activeImg=$(this).find('img').attr('src').split('@')[0];
			console.log(imgs+','+activeImg);
			wx_share.showImg(imgs,activeImg);
		})
	});
}


</script>
</body></html>
